package com.ninthgroup.util;

import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

/**
 * @create by: 1452863884@qq.com rcg
 * @description: 获取web中的request对象和session对象
 * @create time: 2022/10/13 20:10
 * @param
 * @return
 */
public class WebUtil {

    public static HttpSession getSession() {
        HttpSession session = getRequest().getSession();
        return session;
    }

    public static HttpServletRequest getRequest() {
        HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
        return request;
    }
}
